在C或C++中如何使用PI(π)值 您所在的位置:网站首页 宏定义define pi 31416中定义pi 在C或C++中如何使用PI(π)值

在C或C++中如何使用PI(π)值

2024-07-07 11:04| 来源: 网络整理| 查看: 265

#include #define PI acos(-1)

主要是利用利用数学函数中的反三角函数,但是要注意一定引入math包 arccos ⁡ ( − 1 ) = π \arccos(-1)=\pi arccos(−1)=π

完整示例:

//#define LOCAL #include #include #include using namespace std; #define PI acos(-1) int main() { printf("%.30lf\n",PI); return 0; }

结果: 位数一般够了。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有